package org.example.controller;

import jakarta.annotation.Resource;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.example.client.TestFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RefreshScope
public class TestController {
    @Autowired
    RestTemplate restTemplate;
    @Autowired
    private TestFeignClient testFeignClient;

    @Autowired
    private RocketMQTemplate rocketMQTemplate;
    @Value("${test}")
    private String value;
    @Value("${shareq}")
    private String shareq;
    @Value("${testa}")
    private String testa;
    @GetMapping("/testMQ")
    public String testMQ() {
        SendResult sendResult = rocketMQTemplate.syncSend("nodes", "这是一条消息");
        System.out.println(sendResult);
        return "1111";
    }

    @GetMapping("/test")
    public String test() throws InterruptedException {
        Thread.sleep(200);
        return shareq+testa;
    }
    @GetMapping("/lb")
    public String lb() {
      return   restTemplate.getForObject("http://cloud-user1/test", String.class);
    }
    @GetMapping("/testFeign")
    public String testFeign() {
        return testFeignClient.test();
    }
}
